package com.medicine.sys.controller;

import com.medicine.common.base.ResponseData;
import com.medicine.sys.entity.Department;
import com.medicine.sys.entity.Merchant;
import com.medicine.sys.param.DepartmentParam;
import com.medicine.sys.param.MerchantParam;
import com.medicine.sys.service.DepartmentService;
import com.medicine.sys.service.MerchantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "商户管理")
@RestController
@RequestMapping("/merchant")
public class MerchantController {

    @Autowired
    private MerchantService merchantService;

    @ApiOperation(value="商户列表查询")
    @GetMapping("/list")
    public ResponseData list(MerchantParam merchantParam){
        return ResponseData.success("查询成功！",merchantService.selectList(merchantParam));
    }

    @ApiOperation(value="商户新增")
    @PostMapping
    public ResponseData install(Merchant merchant){
        merchantService.install(merchant);
        return ResponseData.success("新增成功！");
    }


    @ApiOperation(value="商户修改")
    @PutMapping
    public ResponseData update(Merchant merchant){
        merchantService.install(merchant);
        return ResponseData.success("修改成功！");
    }

    @ApiOperation(value="商户详情查询")
    @GetMapping("/{id}")
    public ResponseData list(@PathVariable String id){
        return ResponseData.success("查询成功！",merchantService.getId(id));
    }
}
